//
//  AdWebViewController.m
//  51-Tour
//
//  Created by xiang ying on 14-4-13.
//  Copyright (c) 2014年 xiang ying. All rights reserved.
//

#import "AdWebViewController.h"

@interface AdWebViewController ()<UIWebViewDelegate>{
    UIWebView       *_webView;
    
    UIActivityIndicatorView *loading;
}

@end

@implementation AdWebViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self initNavigationItme:@""];
    _webView = [[UIWebView alloc] initWithFrame:self.contentView.frame];
    _webView.delegate = self;
    [self.view addSubview:_webView];
    
    [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[DataCenter instance].adUrl]]];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
    return YES;
}

- (void)webViewDidStartLoad:(UIWebView *)webView{
    loading = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    loading.center = CGPointMake(160, webView.center.y);
    [loading startAnimating];
    [webView addSubview:loading];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView{
    [loading stopAnimating];
    [loading removeFromSuperview];
    
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
    
}

@end
